package com.bsh.controller.system;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bsh.mybatis.model.MerchantCategory;
import com.bsh.mybatis.model.PartnerLevel;
import com.bsh.mybatis.model.Region;
import com.bsh.service.MerchantCategoryService;
import com.bsh.service.PartnerLevelService;
import com.bsh.service.RegionService;
import com.bsh.utils.PageJosnMessage;

/**
 * @author gsh
 * @since 0.0.1
 * 
 */
@Controller
public class SelectController {
	private static Logger log = LoggerFactory.getLogger(SelectController.class);
	@Autowired
	HttpServletRequest request;
	@Autowired
	HttpServletResponse response;
	@Autowired
	HttpSession session;
	@Autowired
	RegionService regionServ;
	@Autowired
	MerchantCategoryService cateServ;
	@Autowired
	PartnerLevelService partnerLevelServ;
	
	/**
	 * 取得region列表
	 */
	@ResponseBody
	@RequestMapping(value = "/system/region/{pid}")
	public PageJosnMessage getReionList(@PathVariable(value = "pid") Integer pid) {
		List<Region> res = regionServ.getRegionList(pid);
		PageJosnMessage msg = new PageJosnMessage();
		msg.putData("regionList", res);
		return msg;
	}
	
	/**
	 * 取得商家分类列表
	 */
	@ResponseBody
	@RequestMapping(value = "/system/catagory")
	public PageJosnMessage getMerchantCatgoryList() {
		List<MerchantCategory> res = cateServ.getCategoryList();
		PageJosnMessage msg = new PageJosnMessage();
		msg.putData("catList", res);
		return msg;
	}
	
	/**
	 * 取得合作伙伴级别列表
	 */
	@ResponseBody
	@RequestMapping(value = "/system/partner/level")
	public PageJosnMessage getPartnerLeveList() { 
		List<PartnerLevel> res = partnerLevelServ.getPartnerLevelList();
		PageJosnMessage msg = new PageJosnMessage();
		msg.putData("catList", res);
		return msg;
	}
}
